Component({
  properties: {
    title: {
      type: String,
      value: '標題' // 默認標題
    },
    type: {
      type: String,
      value: 1 // 默認標題
    },
    size: {
      type: String,
      value: '36rpx' // 默認標題
    },
    backShow: {
      type: Boolean,
      value: false 
    },
    backShow2: {
      type: Boolean,
      value: false 
    },
    share: {
      type: Boolean,
      value: false 
    },
    map: {
      type: Boolean,
      value: false 
    },
    collect: {
      type: Boolean,
      value: false 
    },
  },
  pageLifetimes: {
    show: function() {
      // 頁面被展示
      const systemInfo = wx.getWindowInfo();
      // const getDeviceInfo = wx.getDeviceInfo()
      const statusBarHeight = systemInfo.statusBarHeight;
      const capsuleInfo = wx.getMenuButtonBoundingClientRect();
      console.log('systemInfo',systemInfo);
      console.log('capsuleInfo',capsuleInfo);
      // if(getDeviceInfo.system.toLowerCase().includes('ios')){
      //   this.setData({
      //     ios:true
      //   })
      // }
      this.setData({
        statusBarHeight: capsuleInfo.top,
        timebar:statusBarHeight,
        navBarHeight: capsuleInfo.height,
        navHeight: capsuleInfo.bottom,
        capsuleInfo: capsuleInfo,
        capsulePaddingRight:capsuleInfo.width// 計算膠囊寬度到右側距離
      });
      // console.log(capsuleInfo);
    },
  },
  data: {
    statusBarHeight: 20,  // 狀態欄高度
    navBarHeight: 44,     // 導航欄高度
    capsuleInfo: {},      // 膠囊信息
    navHeight: 64,        // 整個導航欄高度
    capsulePaddingRight: 0, // 計算膠囊寬度到右側距離
    shareShow:false,
    showModal: false
  },
  lifetimes: {
    created() {

    }
  },
  methods: {
    // 返回按鈕事件
    onBackTap() {
      wx.navigateBack();
    },
    onBackTap2() {
      wx.redirectTo({
        url: '/pages/home/home',
      })
    },
    shareClick(){
      this.setData({ shareShow: true });
      
    },
    closePopup() {
      this.setData({ shareShow: false });
    },
    stopTap() {
      // 阻止冒泡，不讓點擊內容區關閉
    },
     // 復製方法
  copyClick(e) {
    const text = e.currentTarget.dataset.text;
    wx.setClipboardData({
      data: text,
      success: () => {
        wx.showToast({
          title: '鏈接已復製',
          icon: 'none',
          duration: 2000
        });
      },
      fail: () => {
        wx.showToast({
          title: '複製失敗',
          icon: 'none'
        });
      }
    });
  },
    shareImgClick(){

    },
    wechatClick(){
      this.setData({ 
        showModal: true,
        shareShow:false
       });
    },
    onInvite() {
      wx.showToast({
        title: '已邀請',
        icon: 'success'
      });
      this.setData({ showModal: false });
    },
  }
});
